<?php
/**
 * 
 */
class UserRecord extends TActiveRecord
{
	const TABLE='tbl_user';

	public $ID;
	public $UserName;	
	public $Email;
	public $Password;
	public $Status=0;	
	public $Gender;
	public $AgeGroup;
	public $PreferredCuisine;
	public $ReceiveUpdates;	
	public $Photo;			
	public $Points=0;		
	public $Hash="";
	public $IPAddress="";
	public $CreateBy;
	public $ModifyBy;
	public $CreateDate=0;
	public $ModifyDate=0;
	
	public static $COLUMN_MAPPING=array
	(
		'user_id'=>'ID',
		'user_name'=>'UserName',
		'user_email'=>'Email',
		'user_pwd'=>'Password',
		'user_status'=>'Status',
		'user_gender'=>'Gender',
		'user_age_group'=>'AgeGroup',
		'preferred_cuisine'=>'PreferredCuisine',
		'receive_updates'=>'ReceiveUpdates',				
		'user_photo'=>'Photo',									
		'user_point'=>'Points',			
		'user_hash'=>'Hash',
		'ip_address'=>'IPAddress',
		'c_by'=>'CreateBy',
		'm_by'=>'ModifyBy',
		'c_date'=>'CreateDate',
		'm_date'=>'ModifyDate'
	);

	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}
	
	public function save()
	{
		if ($this->ID <= 0)
		{
			$this->CreateDate = time();
		}
		$this->ModifyDate = time();
		parent::save();
	}
	
	public function getAllItems()
	{
		$criteria = new TActiveRecordCriteria;
		$criteria->Condition = "user_id > 0";
		return self::finder()->findAll($criteria);
	}
}
?>